/*
 * @(#) $Header$
 *
 * Copyright (C) 2010  Forklabs Daniel Léonard
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package ca.forklabs.crypto;

import java.security.Provider;
import ca.forklabs.crypto.md.Cellhash;
import ca.forklabs.crypto.md.MD2;
import ca.forklabs.crypto.md.MD4;
import ca.forklabs.crypto.md.MD4Ext;
import ca.forklabs.crypto.md.MD5;
import ca.forklabs.crypto.md.RIPEMD;
import ca.forklabs.crypto.md.RIPEMD128;
import ca.forklabs.crypto.md.RIPEMD160;
import ca.forklabs.crypto.md.RIPEMD256;
import ca.forklabs.crypto.md.RIPEMD320;
import ca.forklabs.crypto.md.SHA0;
import ca.forklabs.crypto.md.SHA1;
import ca.forklabs.crypto.md.SHA256;
import ca.forklabs.crypto.md.SHA384;
import ca.forklabs.crypto.md.SHA512;
import ca.forklabs.crypto.md.Tiger;

/**
 * Class {@code Forklabs} is the cryptographic provider for the algorithms in
 * library <em>forklabs-crypto</em>.
 *
 * @author   <a href="mailto:forklabs at gmail.com?subject=ca.forklabs.crypto.Forklabs">Daniel Léonard</a>
 * @version $Revision$
 */
public final class Forklabs extends Provider {

//---------------------------
// Class variables
//---------------------------

   /** serialVersionUID */
   private static final long serialVersionUID = -4781451869771505323L;

   /**
    * The name of this provider, literally "{@code Forklabs}".
    */
   @SuppressWarnings("nls")
   public static final String NAME = "Forklabs";

   /**
    * The version of this provider, {@code 1.0}.
    */
   public static final double VERSION = 1.0;

   /**
    * Informations about this provider, literally "{@code Forklabs's cryptographic provider (forklabs at gmail.com)}".
    */
   @SuppressWarnings("nls")
   public static final String INFO = "Forklabs's cryptographic provider (forklabs at gmail.com)";


//---------------------------
// Algorithm variables
//---------------------------

// message digests

   /**
    * Mnemonic for the MD2 message digest.
    * @see   ca.forklabs.crypto.md.MD2
    */
   public static final String MD_2 = MD2.NAME;

   /**
    * Mnemonic for the MD4 message digest.
    * @see   ca.forklabs.crypto.md.MD4
    */
   public static final String MD_4 = MD4.NAME;

   /**
    * Mnemonic for the MD4 message digest extension.
    * @see   ca.forklabs.crypto.md.MD4Ext
    */
   public static final String MD_4_Ext = MD4Ext.NAME;

   /**
    * Mnemonic for the MD5 message digest.
    * @see   ca.forklabs.crypto.md.MD5
    */
   public static final String MD_5 = MD5.NAME;

//   /**
//    * Mnemonic for the Panama message digest.
//    * @see   fork.crypto.md.Panama
//    */
//   public static final String PANAMA = "PANAMA";

   /**
    * Mnemonic for the RIPEMD message digest.
    * @see   ca.forklabs.crypto.md.RIPEMD
    */
   public static final String RIPE_MD = RIPEMD.NAME;

   /**
    * Mnemonic for the RIPEMD128 message digest.
    * @see   ca.forklabs.crypto.md.RIPEMD128
    */
   public static final String RIPE_MD_128 = RIPEMD128.NAME;

   /**
    * Mnemonic for the RIPEMD160 message digest.
    * @see   ca.forklabs.crypto.md.RIPEMD160
    */
   public static final String RIPE_MD_160 = RIPEMD160.NAME;

   /**
    * Mnemonic for the RIPEMD256 message digest.
    * @see   ca.forklabs.crypto.md.RIPEMD256
    */
   public static final String RIPE_MD_256 = RIPEMD256.NAME;

   /**
    * Mnemonic for the RIPEMD320 message digest.
    * @see   ca.forklabs.crypto.md.RIPEMD320
    */
   public static final String RIPE_MD_320 = RIPEMD320.NAME;

   /**
    * Mnemonic for the SHA0 message digest.
    * @see   ca.forklabs.crypto.md.SHA0
    */
   public static final String SHA_0 = SHA0.NAME;

   /**
    * Mnemonic for the SHA1 message digest.
    * @see   ca.forklabs.crypto.md.SHA1
    */
   public static final String SHA_1 = SHA1.NAME;

   /**
    * Mnemonic for the SHA256 message digest.
    * @see   ca.forklabs.crypto.md.SHA256
    */
   public static final String SHA_256 = SHA256.NAME;

   /**
    * Mnemonic for the SHA384 message digest.
    * @see   ca.forklabs.crypto.md.SHA384
    */
   public static final String SHA_384 = SHA384.NAME;

   /**
    * Mnemonic for the SHA512 message digest.
    * @see   ca.forklabs.crypto.md.SHA512
    */
   public static final String SHA_512 = SHA512.NAME;

   /**
    * Mnemonic for the SNEFRU message digest.
    * @see   ca.forklabs.crypto.md.SNEFRU
    */
   public static final String SNEFRU = ca.forklabs.crypto.md.SNEFRU.NAME;

   /**
    * Mnemonic for the HAVAL message digest.
    * @see   ca.forklabs.crypto.md.HAVAL
    */
   public static final String HAVAL = ca.forklabs.crypto.md.HAVAL.NAME;

   /**
    * Mnemonic for the Tiger message digest.
    * @see   ca.forklabs.crypto.md.Tiger
    */
   public static final String TIGER = Tiger.NAME;

   /**
    * Mnemonic for the Cellhash message digest.
    * @see   ca.forklabs.crypto.md.Cellhash
    */
   public static final String CELLHASH = Cellhash.NAME;

// ciphers
// MACs
// signature
// random number
// key generator


//---------------------------
// Constructors
//---------------------------

   /**
    * Constructor.
    */
   public Forklabs() {
      super(NAME, VERSION, INFO);
      this.setup();
      }


//---------------------------
// Instance methods
//---------------------------

   /**
    * Sets up the message digests.
    */
   @SuppressWarnings("nls")
   protected void setupMessageDigests() {
      this.put("MessageDigest." + Forklabs.CELLHASH   , "ca.forklabs.crypto.md.Cellhash");
      this.put("MessageDigest." + Forklabs.HAVAL      , "ca.forklabs.crypto.md.HAVAL");
      this.put("MessageDigest." + Forklabs.MD_2       , "ca.forklabs.crypto.md.MD2");
      this.put("MessageDigest." + Forklabs.MD_4       , "ca.forklabs.crypto.md.MD4");
      this.put("MessageDigest." + Forklabs.MD_4_Ext   , "ca.forklabs.crypto.md.MD4Ext");
      this.put("MessageDigest." + Forklabs.MD_5       , "ca.forklabs.crypto.md.MD5");
//      this.put("MessageDigest." + Fork.PANAMA       , "fork.crypto.md.PANAMA");
      this.put("MessageDigest." + Forklabs.RIPE_MD    , "ca.forklabs.crypto.md.RIPEMD");
      this.put("MessageDigest." + Forklabs.RIPE_MD_128, "ca.forklabs.crypto.md.RIPEMD128");
      this.put("MessageDigest." + Forklabs.RIPE_MD_160, "ca.forklabs.crypto.md.RIPEMD160");
      this.put("MessageDigest." + Forklabs.RIPE_MD_256, "ca.forklabs.crypto.md.RIPEMD256");
      this.put("MessageDigest." + Forklabs.RIPE_MD_320, "ca.forklabs.crypto.md.RIPEMD320");
      this.put("MessageDigest." + Forklabs.SHA_0      , "ca.forklabs.crypto.md.SHA0");
      this.put("MessageDigest." + Forklabs.SHA_1      , "ca.forklabs.crypto.md.SHA1");
      this.put("MessageDigest." + Forklabs.SHA_256    , "ca.forklabs.crypto.md.SHA256");
      this.put("MessageDigest." + Forklabs.SHA_384    , "ca.forklabs.crypto.md.SHA384");
      this.put("MessageDigest." + Forklabs.SHA_512    , "ca.forklabs.crypto.md.SHA512");
      this.put("MessageDigest." + Forklabs.SNEFRU     , "ca.forklabs.crypto.md.SNEFRU");
      this.put("MessageDigest." + Forklabs.TIGER      , "ca.forklabs.crypto.md.Tiger");
      }

   /**
    * Sets up the ciphers.
    */
   protected void setupCiphers() {
   // no ciphers yet
      }

   /**
    * Sets up the signatures.
    */
   protected void setupSignatures() {
   // no signatures yet
      }

   /**
    * Sets up the key generators.
    */
   protected void setupKeyGenerators() {
   // no key generators yet
      }

   /**
    * Sets up the random number generators.
    */
   protected void setupRandomNumberGenerators() {
   // no random number generators yet
      }

   /**
    * Sets up the message authentication codes.
    */
   protected void setupMACs() {
   // no MACs yet
      }

   /**
    * Sets up the provider.
    */
   protected void setup() {
      this.setupMessageDigests();
      this.setupCiphers();
      this.setupSignatures();
      this.setupKeyGenerators();
      this.setupRandomNumberGenerators();
      this.setupMACs();
      }

   }
